package com.fsnbigdata.handle;
/**
 * Created by Administrator on 2019/3/18.
 */

import com.fsnbigdata.security.auth.TokenHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Description
 * @Author
 * @Date 2019/3/18 11:14
 **/

public class MyInterceptor implements HandlerInterceptor {

    @Autowired
    private TokenHelper tokenHelper;
    @Override
    public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object handler) throws Exception {

        return true;
    }

    @Override
    public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object handler, ModelAndView modelAndView) throws Exception {
        //获取handelMethod对象
        if (!(handler instanceof HandlerMethod)) {
            return ;
        }

    }

    @Override
    public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
        if (e != null){
            System.out.println("异常:"+e.getStackTrace());
        }
    }
}
